import { newRule } from "@/utils/index";
import { FormOption } from "@/components/SuperForm/formType";
interface parmas {
  mapId: number;
  data?: object;
}

export class FormArea {
  #formData: any = {
    zoneFunction: -1,
    zoneNameEn: "",
    zoneName: "",
    areaCoordinates: "",
  };

  #formOption: FormOption = {
    formItems: [
      {
        field: "zoneNameEn",
        prop: "zoneNameEn",
        disabled: true,
        type: "input",
        label: "功能区ID",
        colSpan: 24,
        maxlength: 24,
      },
      {
        field: "areaCoordinates",
        prop: "areaCoordinates",
        type: "input",
        label: "功能区坐标",
        placeholder: "",
        disabled: true,
        colSpan: 24,
        maxlength: 10,
      },
      {
        field: "zoneName",
        prop: "zoneName",
        type: "input",
        label: "功能区名称",
        placeholder: "请输入功能区名称",
        colSpan: 24,
        maxlength: 10,
      },
      {
        field: "zoneFunction",
        prop: "zoneFunction",
        type: "select",
        label: "功能区类型",
        options: [
          {
            label: "持续开关门区域",
            value: 1,
          },
          {
            label: "持续呼梯关梯区域",
            value: 2,
          },
        ],
        placeholder: "请选择功能区类型",
        colSpan: 24,
      },
    ],
    labelWidth: "120px", //标签的长度
  };

  #formRules = {
    zoneNameEn: [newRule(true, "请输入功能区ID", "blur")],
    zoneName: [newRule(true, "请输入功能区名称", "blur")],
    zoneFunction: [newRule(true, "请选择功能区域", "change")],
  };
  get formData() {
    return this.#formData;
  }
  get formRules() {
    return this.#formRules;
  }
  get formOption() {
    return this.#formOption;
  }
  public getFormOption(optionParams?: parmas) {
    // const p1 = getSelectDeviceByType({deviceTypes: '3,4', page:1, limit:1000}).then((res: any) => {
    //   const items = res.devices.items
    //    const deviceOptions = items.map((item: any) => {
    //     return {
    //       label: item.deviceName,
    //       value: item.deviceId
    //     }
    //   })
    //   const deviceId = this.#formOption.formItems.find((item) => item.field === "deviceId")
    //   deviceId && (deviceId.options = deviceOptions)
    // });
    // return Promise.all([p1]);
  }
}
